package controller.admin.category;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import model.entity.Category;
import service.Impl.CategoryServiceImpl;
import util.ResultUtil;
import java.io.IOException;
import java.util.List;

@WebServlet("/admin/category/list")
public class CategoryByTypeController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        CategoryServiceImpl impl=new CategoryServiceImpl();
        int type=Integer.parseInt(req.getParameter("type"));
        List<Category> categoryList=impl.Find(type);
        String json= ResultUtil.getJSON(categoryList);
        resp.getWriter().write(json);
    }
}
